#include <iostream>
#include <vector>
#include <stdio.h>
#include <sstream>
using namespace std;
int MAX1(struct student* q,int n);
int MIN1(struct student* q,int n);
int MAX2(struct student* q,int n);
int MIN2(struct student* q,int n);

struct student{
    char name[20];
    int sex;
    int birth;
    float height;
    int C;
    int Math;
}s[256];
int main() {
    int n = 0;
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%s", &s[i].name, 21);
        scanf("%d", &s[i].sex);
        scanf("%d", &s[i].birth);
        scanf("%f", &s[i].height);
        scanf("%d", &s[i].C);
        scanf("%d", &s[i].Math);
    }
    int suml = 0;
    for(int i = 0; i < n; i++){
        suml+=s[i].C;
    }
    int C_average = suml / n;
    int C_max = MAX1(s, n);
    int C_min = MIN1(s, n);
    int a[256],j=0;
    for (int i = 0; i < n; i++){
        if(C_max == s[i].C){
            a[j] = i;
            j++;
        }
    }
    int sum2 = 0;
    for (int i = 0; i < n; i++){
        sum2 += s[i].Math;
    }
    int Calculus_average = sum2 / n;
    int Calculus_max = MAX2(s, n);
    int Calculus_min = MIN2(s, n);
    int b[256],m=0;
    for (int i = 0; i < n; i++){
        if(Calculus_max == s[i].Math){
            b[m] = i;
            m++;
        }
    }
    printf("C_average:%d\n", C_average);
    printf("C_max:%d\n", C_max);
    for(int i = 0; i < j; i++){
        printf("%s %d %d %.2f %d %d\n", s[a[i]].name, s[a[i]].sex, s[a[i]].birth, s[a[i]].height, s[a[i]].C, s[a[i]].Math);
    }
    printf("C_min:%d\n", C_min);
    printf("Calculus_average:%d\n", Calculus_average);
    printf("Calculus_max:%d\n", Calculus_max);
    for (int i = 0; i < m ; i++){
        printf("%s %d %d %.2f %d %d\n", s[b[i]].name, s[b[i]].sex, s[b[i]].birth, s[b[i]].height,s[b[i]].C, s[b[i]].Math);
    }
    printf("Calculus_min:%d\n", Calculus_min);
    return 0;
}
int MAX1(struct student* q,int n){
    int c=q[0].C;
    for(int i = 1; i < n; i++){
        if(q[i].C > c)  c=q[i].C;
    }
    return c;
}
int MIN1(struct student* q,int n){
    int c=q[0].C;
    for(int i = 1; i < n; i++){
        if(q[i].C < c)  c=q[i].C;
    }
    return c;
}
int MAX2(struct student* q,int n){
    int c=q[0].Math;
    for(int i = 1; i < n; i++){
        if(q[i].Math > c)  c=q[i].Math;
    }
    return c;
}
int MIN2(struct student* q,int n){
    int c=q[0].Math;
    for(int i = 1; i < n; i++){
        if(q[i].Math < c)  c=q[i].Math;
    }
    return c;
}

